//
//  MBProgressTool.m
//  MiaMind
//
//  Created by Vill on 2023/11/24.
//

#import "MBProgressTool.h"

@implementation MBProgressTool

+ (void)mb_showHUDInView:(UIView *)view{
    
    NSLog(@"keywindow -------- %@",[AIUIHelperManager keyWindow]);
    
    MBProgressHUD * hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
    hud.mode = MBProgressHUDModeCustomView;
    UIImageView * gifImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"ai_base_loading"]];
    CABasicAnimation *animation = [ CABasicAnimation
                                   animationWithKeyPath: @"transform" ];
    animation.fromValue = [NSValue valueWithCATransform3D:CATransform3DIdentity];
    // 围绕Z轴旋转，垂直与屏幕
    animation.toValue = [ NSValue valueWithCATransform3D:
                         CATransform3DMakeRotation(M_PI/2.0, 0.0, 0.0, 1.0) ];
    animation.duration = 0.5;
    animation.removedOnCompletion = NO;
    // 旋转效果累计，先转180度，接着再旋转180度，从而实现360旋转
    animation.cumulative = YES;
    animation.repeatCount = HUGE_VALF;
    [gifImageView.layer addAnimation:animation forKey:nil];
    hud.customView = gifImageView;
    hud.bezelView.style = MBProgressHUDBackgroundStyleSolidColor;
    hud.bezelView.color = [UIColor clearColor];
}

+ (void)mb_hideHUDInView:(UIView *)view{
    [MBProgressHUD hideHUDForView:view animated:YES];
}
@end
